﻿<?php
//客户管理类
class CoursesAction extends CommonAction {
	public function index() {
		parent::userauth2(110);
		$data['start'] = empty($_GET['page'])?1:($_GET['page']);
		$data['pageSize'] = 8;
		$data['status'] = !isset($_GET['s'])?' ':$_GET['s'];
		$data['site'] = !isset($_GET['site'])?' ':$_GET['site'];
		
		//$data['courseName'] = '';
		if (!empty($_GET['courseName'])) {
			$data['courseName']=$_GET['courseName'];
		}
		$html = send_post(C('SMART_URL').'/smart/course/manger/queryCourseList',$data);

		$count = $html['data']['courseInfo']['totalRowNumber'];
		$list = $html['data']['courseInfo']['dataList'];
//		dump($list);
		import('ORG.Util.Page');				// 导入分页类
		$pagenum = isset ( $_REQUEST ['page'] ) ? $_REQUEST ['page'] : 1;
		$page_row = $data['pageSize'];//每页显示条数
		$p = new Page ($count,$page_row,8);
		$p->isJumpPage = true;
		$p->setConfig('theme','%totalRow% %header% %nowPage%/%totalPage% 页%first% %upPage% %linkPage% %downPage% %end% %jump%');
		$show = $p->show();
		$this->assign('list',$list);
		$this->assign('courseName',$data['courseName']);
		$this->assign('page',$show);
		$this->assign('newsurl',C('NEWSURL'));
		$this->assign('url',C('URL'));
		$this->assign('admin',$_SESSION['ThinkUser']);

		$this->assign('status', D('status')->field('id, name, value')->order('id asc')->where('pid = 2')->select());
		$this->assign('site', D('status')->field('id, name, value')->order('id asc')->where('pid = 6')->select());

		$this->display();
	}
	public function CourseInfo() {
		$data['courseId']= $_GET['sid'];
		$html = send_post(C('SMART_URL').'/smart/course/manger/queryCourseDetail',$data);
		$this->assign('code',$html['code']);
		$this->assign('user',$html['data']['course']);
		$this->assign('smartUser',$html['data']['smartUser']);
		$this->assign('url',C('URL'));
		$this->display();		
	}

	public function audit() {
		
		$data['courseId']= $_GET['sid'];
		$html = send_post(C('SMART_URL').'/smart/course/manger/queryCourseDetail',$data);
		$this->assign('code',$html['code']);
		$this->assign('course',$html['data']['course']);
		$this->assign('url',C('URL'));
		$this->display();		
	}

	public function update(){
		$courseId='';
		$comment='';
		$status='';
		if (!empty($_POST['id'])) {
			$courseId=$_POST['id'];
		}
		if (!empty($_POST['comment'])) {
			$comment=$_POST['comment'];
		}
		if (!empty($_POST['status'])) {
			$status=$_POST['status'];
		}else{
			$status='0';
		}
		if ($courseId!='' and $comment!='' and $status!='' ) {
			$data['courseId']= $courseId;
			$data['comment']= $comment;
			$data['status']= $status;
			$html = send_post(C('SMART_URL').'/smart/course/manger/updateCourse',$data);
			if ($html['code']==2000) {
				$this->success('修改成功',__APP__.'/Course/index');
			}else{
				$this->error($html,__APP__.'/Course/index');	
			}					
		}else{
			$this->error($courseId.' '.$comment.' '.$status,__APP__.'/Course/index');
		}

	}


}
?>

